lib/deploy: Support locking deployment finalization
authorJonathan Lebon <jonathan@jlebon.com>
Tue, 16 Apr 2019 21:12:08 +0000 (17:12 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Wed, 24 Apr 2019 21:38:24 +0000 (21:38 +0000)
Teach `ostree-finalize-staged.service` to check for a file in `/run` to
determine if it should do the finalization. This will be used in
RPM-OSTree, where we want to be able to separate out "preparing updates"
from "making update the default" for more fine-grained control. See:
https://github.com/projectatomic/rpm-ostree/issues/1748

Closes: #1841
Approved by: cgwalters

src/libostree/ostree-sysroot-deploy.c
src/libostree/ostree-sysroot-private.h

index ce11fe67cc365d624c8c7e2c3e885508eb9104d1..3ca6c148c1e86f5f20bcd9f703e2ff09bd647fa7 100644 (file)
@@ -2886,6 +2886,17 @@ _ostree_sysroot_finalize_staged (OstreeSysroot *self,
       return TRUE;
     }
 
+  /* Check if finalization is locked. */
+  if (!glnx_fstatat_allow_noent (AT_FDCWD, _OSTREE_SYSROOT_RUNSTATE_STAGED_LOCKED,
+                                 NULL, 0, error))
+    return FALSE;
+  if (errno == 0)
+    {
+      ot_journal_print (LOG_INFO, "Not finalizing; found "
+                                  _OSTREE_SYSROOT_RUNSTATE_STAGED_LOCKED);
+      return TRUE;
+    }
+
   /* Notice we send this *after* the trivial `return TRUE` above; this msg implies we've
    * committed to finalizing the deployment. */
     ot_journal_send ("MESSAGE_ID=" SD_ID128_FORMAT_STR,
index 9da6d4c9e1e64bd8ac3a6efc2f1c9ce5fc42d512..e4b2039e2fa7a13ac8a5612b7028eb26ed9092d7 100644 (file)
@@ -76,6 +76,7 @@ struct OstreeSysroot {
 #define OSTREE_SYSROOT_LOCKFILE "ostree/lock"
 /* We keep some transient state in /run */
 #define _OSTREE_SYSROOT_RUNSTATE_STAGED "/run/ostree/staged-deployment"
+#define _OSTREE_SYSROOT_RUNSTATE_STAGED_LOCKED "/run/ostree/staged-deployment-locked"
 #define _OSTREE_SYSROOT_DEPLOYMENT_RUNSTATE_DIR "/run/ostree/deployment-state/"
 #define _OSTREE_SYSROOT_DEPLOYMENT_RUNSTATE_FLAG_DEVELOPMENT "unlocked-development"